#include <bits/stdc++.h>

using namespace std;
#define int long long
const int inf = 0x3f3f3f3f;

void solve()
{
    int n;
    cin >> n;
    priority_queue<int> q;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        q.push(x);
    }
    int sum1 = 0, sum2 = 0, cnt = 0;
    while (q.size())
    {
        int x = q.top();
        q.pop();
        if (cnt == 0) sum1 += x;
        else sum2 += x;
        cnt ^= 1;
    }
    cout << sum1 << ' ' << sum2;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int _ = 1;
    //cin >> _;
    while (_--)
    {
        solve();
    }
    return 0;
}